/**
 * elancom Corporation copy right 2012 - 2015  
 *   
 * $Header: https://192.168.1.224/svn/elancom/product/elancom-platform/trunk/src/main/java/com/elancom/framework/util/Assert.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Id: Assert.java 1034 2012-07-02 03:09:12Z lanzhouxue $
 * $Author: lanzhouxue $
 * $Date: 2012-07-02 11:09:12 +0800 (Mon, 02 Jul 2012) $
 * $Revision: 1034 $
 */
package com.elancom.framework.commons.util;

/**
 * @author elancom
 * @date 2012-8-27
 */
public abstract class Assert {
	public static void isNotNull(Object obj) {
		isNotNull("obj is not null", obj);
	}

	public static void isNotNull(String errorMessage, Object... objs) {
		if (objs == null) {
			throw new AssertException(errorMessage);
		}
		for (Object o : objs) {
			if (o == null) {
				throw new AssertException(errorMessage);
			}
		}
	}

	public static void isNull(Object obj) {
		if (obj != null) {
			throw new AssertException("obj is not null");
		}
	}

	public static void isNull(Object obj, String errorMessage) {
		if (obj != null) {
			throw new AssertException(errorMessage);
		}
	}

	public static void isTrue(boolean bl, String message) {
		if (!bl) {
			throw new AssertException(message);
		}
	}

	public static void notBlank(Object obj, String message) {
		if (obj == null || obj.toString().trim().length() == 0) {
			throw new AssertException(message);
		}
	}

	/**
	 * 
	 * @param obj
	 * @param errorMessage
	 */
	public static void notNull(Object obj) {
		if (obj == null) {
			throw new AssertException("obj is null");
		}
	}

	/**
	 * @param obj
	 * @param errorMessage
	 */
	public static void notNull(Object obj, String errorMessage) {
		if (obj == null) {
			throw new AssertException(errorMessage);
		}
	}

}
